//@flow
/**
 * 主堆栈
 */
import React, { Component } from 'react';
import { 
    View,
 } from 'react-native';
import { 
    createStackNavigator,
    StackViewTransitionConfigs,
    TransitionConfigurer,
 } from "react-navigation";
import { TabNavigator } from "../tabNavigator/index";
import { RequestAnalyzer } from "../../page/requestAnalyzer/requestAnalyzer";
import { LoginStack } from './loginStack';

/**react navigation仍然不支持单个视图以modal的形式显示,写个动画方法进行创造 */

//配置需要模态显示的界面名字
const MODAL_SCREEN = ['LoginStack'];

//模态显示的方法
const transitionAnimated = (transitionProps, prevTransitionProps):TransitionConfigurer=>{
    let isModal : boolean = MODAL_SCREEN.some((value,index,arr)=>{
        return value === transitionProps.scene.route.routeName || (prevTransitionProps && value === prevTransitionProps.scene.route.routeName)
    })
    return StackViewTransitionConfigs.defaultTransitionConfig(
        transitionProps,
        prevTransitionProps,
        isModal
    )
}

export const RootStack = createStackNavigator({
    Tab         :TabNavigator,//首页五屏tab内容
    RequestAnalyzer   :RequestAnalyzer,
    LoginStack	:LoginStack,
},{
    headerMode:'none',
    transitionConfig:transitionAnimated,
})